package cn.hesion.Speak;
/**
 * ClassName: Reducer <br/>
 * Description: <br/>
 * date: 2021/2/2 15:15<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @program: ClientDemo
 * @description:
 * @author: hesion
 * @create: 2021-02-02 15:15
 **/
public class SpeakDurationReducer extends Reducer<Text,SpeakBean, Text,SpeakBean> {
    @Override
    protected void reduce(Text key, Iterable<SpeakBean> values, Context context) throws IOException, InterruptedException {
        long self_duration = 0;
        long thirdPart_duration = 0;

        for (SpeakBean sb : values) {
            self_duration= sb.getSelfDuration();
            thirdPart_duration=sb.getThirdPartDuration();
        }

        SpeakBean resultBean = new SpeakBean(self_duration, thirdPart_duration);
        context.write(key,resultBean);
    }
}
